<template>
<el-dialog v-if="visible" :visible.sync="visible" title="评论列表">
  <CommentTable :data-list="commentList" :page-info="pageInfo" :is-dialog="true" @currentChange="currentChange" @sizeChange="sizeChange"/>
  <div slot="footer">
    <el-button type="primary" @click="visible = false">关闭</el-button>
  </div>
</el-dialog>
</template>

<script>
import CommentTable from '@/components/CommentTable'
export default {
  name: 'ArticleComment',
  components: { CommentTable },
  data () {
    return {
      visible: false,
      commentList: [],
      pageInfo: {
        page: 1,
        limit: 5,
        total: 0,
        articleId: '',
        status: 1
      }
    }
  },
  methods: {
    init (articleId) {
      this.pageInfo.articleId = articleId
      this.visible = true
      this.getCommentList()
    },
    getCommentList () {
      this.$http.get('admin/comment/page', this.pageInfo).then(data => {
        this.commentList = data.data.records
        this.pageInfo.page = data.data.current
        this.pageInfo.limit = data.data.size
        this.pageInfo.total = data.data.total
      })
    },
    sizeChange (val) {
      this.pageInfo.size = val
      this.getCommentList()
    },
    currentChange (val) {
      this.pageInfo.page = val
      this.getCommentList()
    }
  }
}
</script>

<style scoped>

</style>
